package widgets

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/widget"
)

type Clicklbl struct {
	widget.Label
	OnTapped       func() `json:"-"`
	OnDoubleTapped func() `json:"-"`
	OnRightTapped func() `json:"-"`
}

// lbl := newClickLbl("lblb", nil,nil)
// lbl.OnDoubleTapped=func() {
// 	lbl.SetText("double")
// }
// lbl.OnTapped=func() {
// 	lbl.SetText("tapped")
// }
func NewClickLbl(txt string, OnTapped, OnDoubleTapped func(),
 OnRightTapped func()) (lbl *Clicklbl) {
	lbl = &Clicklbl{}
	lbl.ExtendBaseWidget(lbl)
	lbl.SetText(txt)
	lbl.OnTapped = OnTapped
	lbl.OnDoubleTapped = OnDoubleTapped
	lbl.OnRightTapped = OnRightTapped
	return
}
func (lbl *Clicklbl) DoubleTapped(*fyne.PointEvent) {
	if lbl.OnDoubleTapped != nil {
		lbl.OnDoubleTapped()
	}
}

func (lbl *Clicklbl) Tapped(*fyne.PointEvent) {
	if lbl.OnTapped != nil {
		lbl.OnTapped()
	}
}

func (lbl *Clicklbl) TappedSecondary(*fyne.PointEvent) {
	if lbl.OnRightTapped != nil {
		lbl.OnRightTapped()
	}
}